<%@ Page Language="C#" MasterPageFile="~/sbMembership.Master" AutoEventWireup="true"
    CodeFile="~/Default.aspx.cs" Inherits="SodaBlue.MembershipWeb.Default" Title="Untitled Page"
    EnableEventValidation="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="MainUpdatePanel" UpdateMode="Conditional" runat="server">
        <ContentTemplate>
            <asp:UpdatePanel ID="MemberGridUpdatePanel" UpdateMode="Conditional" runat="server">
                <ContentTemplate>
                    <asp:LinkButton ID="btnAddNewUser" runat="server" OnClick="btnAddNewUser_Click">Add New User</asp:LinkButton>
                    <asp:LinkButton ID="btnAddNewRole" runat="server" OnClick="btnAddNewRole_Click">Add New Role</asp:LinkButton>
                    <asp:GridView ID="gvMembers" runat="server" CellPadding="4" GridLines="Vertical"
                        AllowPaging="True" AutoGenerateColumns="False" PageSize="25" OnRowCommand="gvMembers_RowCommand"
                        OnRowDeleting="gvMembers_RowDeleting">
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <EditRowStyle BackColor="#999999" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        <Columns>
                            <asp:ButtonField CommandName="SELECT" DataTextField="UserName" HeaderText="UserName" />
                            <asp:BoundField DataField="Email" HeaderText="Email" />
                            <asp:BoundField DataField="CreationDate" HeaderText="Member Since" />
                            <asp:BoundField DataField="LastLoginDate" HeaderText="Last Login Date" />
                            <asp:CheckBoxField DataField="IsApproved" HeaderText="Approved" />
                            <asp:CheckBoxField DataField="IsLockedOut" HeaderText="Locked Out" />
                            <asp:CommandField ShowDeleteButton="True" DeleteText="Delete User" DeleteImageUrl="~/Assets/Images/silk/user_delete.png"
                                ButtonType="Image">
                                <ItemStyle Wrap="False" />
                            </asp:CommandField>
                            <asp:ButtonField CommandName="MODIFYROLES" Text="Modify Roles" ButtonType="Image"
                                ImageUrl="~/Assets/Images/silk/group_edit.png">
                                <ItemStyle Wrap="False" />
                            </asp:ButtonField>
                        </Columns>
                    </asp:GridView>
                    <asp:Button runat="server" ID="hiddenTargetControlForAddUser" Style="display: none" />
                    <ajaxToolkit:ModalPopupExtender ID="NewUserModalPopupExtender" runat="server" TargetControlID="hiddenTargetControlForAddUser"
                        PopupControlID="pnlAddUser" OkControlID="btnUserAddClose" BackgroundCssClass="modalBackground">
                    </ajaxToolkit:ModalPopupExtender>
                    <asp:Button runat="server" ID="hiddenTargetControlForAddRole" Style="display: none" />
                    <ajaxToolkit:ModalPopupExtender ID="NewRoleModalPopupExtender" runat="server" TargetControlID="hiddenTargetControlForAddRole"
                        PopupControlID="pnlAddRole" OkControlID="btnAddRoleClose" BackgroundCssClass="modalBackground">
                    </ajaxToolkit:ModalPopupExtender>
                    <asp:Button runat="server" ID="hiddenTargetControlForUserRoles" Style="display: none" />
                    <ajaxToolkit:ModalPopupExtender ID="UserRolesModalPopupExtender" runat="server" TargetControlID="hiddenTargetControlForUserRoles"
                        PopupControlID="pnlUserRoles" OkControlID="btnUserRolesClose" BackgroundCssClass="modalBackground">
                    </ajaxToolkit:ModalPopupExtender>
                    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="MemberGridUpdatePanel">
                        <ProgressTemplate>
                            Waiting...</ProgressTemplate>
                    </asp:UpdateProgress>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnAddUserOK" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="btnAddRoleOK" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
            <asp:Panel ID="pnlAddUser" runat="server" Style="display: none" CssClass="modalPopup"
                DefaultButton="btnAddUserOK">
                <div class="modalHeader">
                    <asp:ImageButton ID="btnUserAddClose" runat="server" ImageUrl="~/Assets/Images/silk/cancel.png"
                        AlternateText="Close" CssClass="modalHeaderButton" /></div>
                <div class="modalInner">
                    <div style="float: left;">
                        <asp:UpdatePanel ID="AddUserUpdatePanel" runat="server">
                            <ContentTemplate>
                                <asp:Label ID="Label1" runat="server" Text="Username:" EnableViewState="false" CssClass="NormalBold"></asp:Label><br />
                                <asp:TextBox ID="txtUsername" runat="server" EnableViewState="false" ValidationGroup="AddUser"></asp:TextBox><br />
                                <asp:Label ID="Label2" runat="server" Text="Password:" EnableViewState="false" CssClass="NormalBold"></asp:Label><br />
                                <asp:TextBox ID="txtPassword" runat="server" EnableViewState="false" TextMode="Password"
                                    ValidationGroup="AddUser"></asp:TextBox><br />
                                <asp:Label ID="Label3" runat="server" Text="Confirm Password:" EnableViewState="false"
                                    CssClass="NormalBold"></asp:Label><br />
                                <asp:TextBox ID="txtPassword2" runat="server" EnableViewState="false" TextMode="Password"
                                    ValidationGroup="AddUser"></asp:TextBox><br />
                                <asp:Label ID="Label4" runat="server" Text="Email:" EnableViewState="false" CssClass="NormalBold"></asp:Label><br />
                                <asp:TextBox ID="txtEmail" runat="server" EnableViewState="false" ValidationGroup="AddUser"></asp:TextBox><br />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Username is required."
                                    ControlToValidate="txtUsername" Display="None" ValidationGroup="AddUser"></asp:RequiredFieldValidator>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Password is required."
                                    ControlToValidate="txtPassword" Display="None" ValidationGroup="AddUser"></asp:RequiredFieldValidator>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Email is required."
                                    ControlToValidate="txtEmail" Display="None" ValidationGroup="AddUser"></asp:RequiredFieldValidator>
                                <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Passwords must match."
                                    ControlToCompare="txtPassword" ControlToValidate="txtPassword2" Display="None"
                                    ValidationGroup="AddUser"></asp:CompareValidator>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
                                    ErrorMessage="This is not an email address." ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                    Display="None" ValidationGroup="AddUser"></asp:RegularExpressionValidator>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                        <asp:LinkButton ID="btnAddUserOK" runat="server" OnClick="btnAddUserOK_Click" ValidationGroup="AddUser">Add User</asp:LinkButton>
                    </div>
                    <div style="float: right;">
                        <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableViewState="false"
                            ValidationGroup="AddUser" />
                    </div>
                </div>
            </asp:Panel>
            <asp:Panel ID="pnlAddRole" runat="server" Style="display: none" CssClass="modalPopup"
                DefaultButton="btnAddRoleOK">
                <div class="modalHeader">
                    <asp:ImageButton ID="btnAddRoleClose" runat="server" ImageUrl="~/Assets/Images/silk/cancel.png"
                        AlternateText="Close" CssClass="modalHeaderButton" /></div>
                <div class="modalInner">
                    <div style="float: left;">
                        <asp:UpdatePanel ID="AddRoleUpdatePanel" runat="server">
                            <ContentTemplate>
                                <asp:Label ID="Label5" runat="server" Text="Role Name:" EnableViewState="false" CssClass="NormalBold"></asp:Label><br />
                                <asp:TextBox ID="txtRolename" runat="server" EnableViewState="false" ValidationGroup="AddRole"></asp:TextBox><br />
                            </ContentTemplate>
                        </asp:UpdatePanel>
                        <asp:LinkButton ID="btnAddRoleOK" runat="server" ValidationGroup="AddRole" OnClick="btnAddRoleOK_Click">Add Role</asp:LinkButton>
                        <br />
                        <asp:Label ID="lblAddRoleError" runat="server" Text="" CssClass="ErrorRed"></asp:Label>
                    </div>
                </div>
            </asp:Panel>
            <asp:Panel ID="pnlUserRoles" runat="server" Style="display: none" CssClass="modalPopup">
                <div class="modalHeader">
                    <asp:ImageButton ID="btnUserRolesClose" runat="server" ImageUrl="~/Assets/Images/silk/cancel.png"
                        AlternateText="Close" CssClass="modalHeaderButton" /></div>
                <div class="modalInner">
                    <asp:UpdatePanel ID="UserRolesUpdatePanel" runat="server">
                        <ContentTemplate>
                            <asp:Label ID="lblAvailableRoles" runat="server" Text="Available Roles:" CssClass="NormalBold"></asp:Label>
                            <asp:DropDownList ID="ddlAvailableRoles" runat="server">
                            </asp:DropDownList><asp:LinkButton ID="btnUserRoleAdd" runat="server" OnClick="btnUserRoleAdd_Click">Add Role</asp:LinkButton>
                            <br />
                            <asp:Label ID="lblUserRolesError" runat="server" Text="" CssClass="ErrorRed"></asp:Label>
                            <hr />
                            <asp:GridView ID="gvUserRoles" runat="server" AutoGenerateColumns="False" CellPadding="4"
                                ForeColor="#333333" GridLines="Vertical" OnRowCommand="gvUserRoles_RowCommand"
                                OnRowDeleting="gvUserRoles_RowDeleting">
                                <Columns>
                                    <asp:TemplateField ShowHeader="False">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="btnUserRoleDelete" runat="server" CommandName="Delete" CommandArgument="<%# Container.DataItem.ToString() %>"
                                                ImageUrl="~/Assets/Images/silk/group_delete.png" AlternateText="Remove Role" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Roles">
                                        <ItemTemplate>
                                            <%# Container.DataItem.ToString() %>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                <EditRowStyle BackColor="#999999" />
                                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            </asp:GridView>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btnUserRoleAdd" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>
                    <hr />
                </div>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    <anr:CenteredProgressIndicator ID="CenteredProgressIndicator1" runat="server" TargetControlID="ProgressIndicator" />
    <asp:Panel ID="ProgressIndicator" runat="server" CssClass="progress_indicator" Style="display: none;">
        <img id="Img1" src="Assets/Images/ajax-loader.gif" alt="" runat="server" />
    </asp:Panel>
</asp:Content>
